import Vue from 'vue'
import Vuex from 'vuex'
//注册
Vue.use(Vuex)
//实例化仓库
export default new Vuex.Store({
  strict:true,
  state:{
    name:'tom',
    count:0,
    list:[1,2,3,4,5,6,7,8],
    student:{
        name:'tom',
        school:{
            name:'吉山',
            address:{
                city:'广州',
                street:'珠吉路',
                detail:'天河区'
            }
        }
    }
  },
  mutations:{
    setCount(state,data){
      state.count += data
    }
  },
  actions:{
    asyncSetCount(store,data){
       setTimeout(() => {
         store.commit('setCount',data)
       },1000)
    }
  },
  getters:{
      filterList(state){
       return state.list.filter(item=>item>5)
      },
      schoolAddr: state =>state.student.school.address.detail
      
  }
})